const { YIXIANTONG_API } = require('../config/config'),
    Model = require('../libs/Model');

const url = 'http://study.jsplusplus.com/Yixiantong';

class yiXianTongModel extends Model {
    getHomeDatas(cityId) {
        return new Promise((resolve, reject) => {
            this.axiosPost({
                url: url + '/getHomeDatas', 
                data: {
                    cityId
                },
                success(res) {
                    resolve(res);
                },
                error(error) {
                    resolve(error);
                }
            });
        })
    }

    getListDatas(cityId, field) {
        return new Promise((resolve, reject) => {
            this.axiosPost({
                url: url + '/getListDatas', 
                data: {
                    cityId, 
                    field
                },
                success(res) {
                    resolve(res);
                },
                error(error) {
                    resolve(error);
                }
            });
        })
    }

    getDetailDatas(field, id) {
        return new Promise((resolve, reject) => {
            this.axiosPost({
                url: url + '/getDetail', 
                data: {
                    field, 
                    id
                },
                success(res) {
                    resolve(res);
                },
                error(error) {
                    resolve(error);
                }
            });
        })
    }

    searchAction(keyword, cityId) {
        return new Promise((resolve, reject) => {
            this.axiosPost({
                url: url + '/searchAction', 
                data: {
                    keyword, 
                    cityId
                },
                success(res) {
                    resolve(res);
                },
                error(error) {
                    resolve(error);
                }
            });
        })
    }

}

module.exports = new yiXianTongModel();